<template>
  <div>
    <el-table
      ref="multipleTable"
      :data="tableData"
      tooltip-effect="dark"
      style="width: 100%"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55"> </el-table-column>
      <el-table-column label="日期" width="120">
        <template slot-scope="scope">{{ scope.row.date }}</template>
      </el-table-column>
      <el-table-column prop="name" label="姓名" width="120"> </el-table-column>
      <el-table-column prop="address" label="地址" show-overflow-tooltip>
      </el-table-column>
    </el-table>
    <div style="margin-top: 20px">
      <el-button @click="toggleSelection(tableData)"
        >切换第二、第三行的选中状态</el-button
      >
      <el-button @click="toggleSelection()">取消选择</el-button>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      tableData: [

      ],
      multipleSelection: [],
    };
  },
  created() {
    this.findAllRole();
    this.findAllMenu("0")
  },
  methods: {
    openRoleAdminDrawer(roleId){
      this.roleAdminDrawer = true;
      this.findAllMenu(roleId);
    },
    findAllMenu(roleId){
      $findAllMenu(roleId).then((res) =>{
       
        if(res.data.success){
          this.tableData = res.data.data.findAllMenu;
          // this.multipleSelection = res.data.data.wqunSysRoleMenus;
          this.toggleSelection(this.tableData);
          // console.log(this.multipleSelection);
        }else{
          this.message(res);
        }
      })
    },
    toggleSelection(rows) {
      if (rows) {
        rows.forEach((row) => {
          this.$refs.multipleTable.toggleRowSelection(row,true);
        });
      } else {
        this.$refs.multipleTable.clearSelection();
      }
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    findAllMenu(roleId){
      $findAllMenu(roleId).then((res) =>{
       
        if(res.data.success){
          this.drawerData = res.data.data.findAllMenu;
          // this.multipleSelection = res.data.data.wqunSysRoleMenus;
          this.toggleSelection(this.drawerData);
          // console.log(this.multipleSelection);
        }else{
          this.message(res);
        }
      })
    },
  },
};
</script>
